
$(function(){
  $('.pup-close').click(function(){
    const pup = $(this).attr('data-id');
    $('#'+pup).removeClass('show')
  })
  $('.pup-show').click(function(){
    const pup = $(this).attr('data-id');
    $('#'+pup).addClass('show')
    console.log('pup---', pup)
  })
  
  let codeSend = false;
  let codeTxt1 = "获取验证码"
  let codeTxt2 = "s后重新获取"
  const intNum = 60;
  let codeNum = intNum;
  let codeRun = null
  $('#code').click(function(){
    if(codeSend){
      codeSend = false;
    }else{
      codeSend = true;
      codeNum--;
      $('#code').html(codeNum+codeTxt2)
      codeRun = setInterval(()=>{
        codeNum--;
        $('#code').html(codeNum+codeTxt2)
        if(codeNum === 0){
          codeNum = intNum;
          codeSend = false;
          $('#code').html(codeTxt1)
          clearInterval(codeRun)
        }
      },1000)
    }
  })
})

// 表单校验
function validateForm(formSelector) {
  let isValid = true;
  $(formSelector + ' .lab .red').each(function () {
    const lab = $(this).closest('.lab');
    const item = lab.closest('.item');
    const input = item.find('.text, .sfz'); // 可扩展

    const value = $.trim(input.val());

    if (value === '' || value === null || (typeof value === 'string' && !value.trim())) {
      item.addClass('error');
      isValid = false;
    } else {
      item.removeClass('error');
    }
  });
  return isValid;
}

// 右侧通用顶部
function setContentTop(nickname){
 
}

